<?php
//special.php
//Make special graphs
//Written by Hongjie Qu
//Last Updated: August 2009
?>
<html>
<head>
  <title>Sepkoski Curve</title>
	<link rel="stylesheet" type="text/css" href="./styles1/tabber.css">
  <script type="text/javascript" src="./js/tabber.js"></script>
	<SCRIPT LANGUAGE="JavaScript">
function ajaxname(dox){ //called in "Free Form search" part when clicking "search" button


  var ajaxRequest;  // The variable that makes Ajax possible!
    try{
      // Opera 8.0+, Firefox, Safari
        ajaxRequest = new XMLHttpRequest();
    } catch (e){
      // Internet Explorer Browsers
    try{
        ajaxRequest = new ActiveXObject("Msxml2.XMLHTTP");
    } catch (e) {
    try{
        ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
    } catch (e){
      // Something went wrong
        alert("Your browser broke!");
        return false;
    }
    }
    }
  // Create a function that will receive data sent from the server
  ajaxRequest.onreadystatechange = function(){
    if(ajaxRequest.readyState == 4){
	if(dox=="Dvt")  {    
		var ajaxDisplay = document.getElementById('ajaxnameDiv');
		ajaxDisplay.innerHTML = ajaxRequest.responseText;
	}
	else if(dox=="Ext") {
		var ajaxDisplay = document.getElementById('ajaxnameExt');
		
		ajaxDisplay.innerHTML = ajaxRequest.responseText;
	}
	
	else if(dox=="Orig") {
		var ajaxDisplay = document.getElementById('ajaxnameOrig');
		
		ajaxDisplay.innerHTML = ajaxRequest.responseText;
	}
      
    }
  }
  if(dox=="Dvt"){
	var newnametxt = document.getElementById('textnameDvt').value;
  }
  
 else if(dox=="Orig"){
	var newnametxt = document.getElementById('textnameOrig').value;
  }
  else if(dox=="Ext"){
	var newnametxt = document.getElementById('textnameExt').value;
  }
	//var searchtxt ="It is just a test!";
  var queryString = "?newnametxt=" + newnametxt+"&dox="+dox;
	ajaxRequest.open("GET", "newname.php" + queryString, true);
	ajaxRequest.send(null);
}
  
  </script>
 

<?php
    include 'header.php';
  ?>
<body>

<?php

$relative =$_POST['categoricalSpcl'];
if($relative=="Epoch") $relative="stgintv"; //stgintv is the table name, will be a parameter later in this program
if($relative=="Period") $relative="period";
if($relative=="Stage") $relative="stage";
$absolute = $_POST['TimerangeSpcl'];
$from=$_POST['fromSpcl'];
$end=$_POST['endSpcl'];
$label=$_POST['labelSpcl'];
$cat=$_POST['RadioGroup1'];// in form4, each box is onclick submit


$d=$_POST['DiversitySpcl'];
$o=$_POST['OriginationSpcl'];
$e=$_POST['ExtinctionSpcl'];

//echo "d is $d<br>";
//echo "o is $o<br>";
//echo "e is $e<br>";

//echo "cat is $cat<br>";

//echo "from is $from<br>";
//echo "end is $end<br>";
//echo "label is $label<br>";
//echo "relative time is $relative<br>";
//echo "absolute time is $absolute<br>";

if($cat){
$username = "fossilplot";
$password = "fossilplot";
$hostname = "localhost"; 
//echo "hello";
//connection to the database
$dbhandle = mysql_connect($hostname, $username, $password)
 or die("Unable to connect to MySQL");


//select a database to work with
$selected = mysql_select_db("fossilplot",$dbhandle)  or die("Could not select examples");
$cm_classname= "("."'Cl. Polychaeta'".","."'Cl. Orthothecimorpha'".","."'Cl. Hyolithomorpha'".","."'Cl. Helcionelloida \"Monoplacophora\"'".","."'Cl. Helcionelloida \"Monoplacophora\"'".","."'Cl. Trilobita'".",". "'Cl. Inarticulata'".",". "'Cl. Eocrinoidea'".")";
$md_classname="("."'Cl. Demospongia'".","."'Cl. Gastropoda'".","."'Cl. Bivalvia'".","."'Sc. Crustacea, Cl. Malacostraca'".","."'Cl. Gymnolaemata'".","."'Cl. Echinoidea'".","."'Cl. Chondrichthyes'".","."'Cl. Osteichthyes'".")";
$pz_classname="("."'Cl. Anthozoa'".","."'Cl. Cephalopoda'".","."'Sc. Crustacea, Cl. Ostracoda'".","."'Cl. Stenolaemata'".","."'Cl. Articulata'".","."'Asterozoa, Cl. Asteroidea'".","."'Cl. Crinoidea'".","."'Cl. Blastoidea'".")";

  
  
  //$genusId= "("."1".","."2".")";
  //echo "SELECT * FROM genus where class_name in $pz_classname";
  $resultcm = mysql_query("SELECT distinct fad_date, lad_date,count(id) FROM genus where class_name in $cm_classname group by fad_date, lad_date");
  $resultmd = mysql_query("SELECT distinct fad_date, lad_date,count(id) FROM genus where class_name in $md_classname group by fad_date, lad_date");
  $resultpz = mysql_query("SELECT distinct fad_date, lad_date,count(id) FROM genus where class_name in $pz_classname group by fad_date, lad_date");


  
$ydata_arr=array();//for cm
$ydata_arr2=array();//for md classname
$ydata_arr3=array();//for pz classname

$key=1;
if($relative=="none"){
	
	if($from=="" || $end==""|| $absolute==""){
		$key=0;
	}
	if(!(is_numeric($from) && is_numeric($end) && is_numeric($absolute))){
		$key=0;
	}
	if($from<0 ||$from>550||$end<0||$end>550||$absolute<0){
		$key=0;
	}
	
	$abs=abs($from -$end);
	if($abs==0 || ($abs/$absolute)<10 ||($abs/$absolute)>150){
		$key=0;
	}
	
	if($key==1){
		if(is_int($abs/$absolute)){
			$xaxis_num=$abs/$absolute;
		}
		else{
			$xaxis_num=ceil($abs/$absolute);
		}
		
	if($from < $end){
	$tmp=$from;
	$from=$end;
	$end=$tmp;
		
	}
		//echo "xaxis_num is $xaxis_num<br>";
		for($tmp=0; $tmp<$xaxis_num; $tmp++ ){
		  $ydata_arr[$tmp]=0;
		  $ydata_arr_dvt[$tmp]=0;
		  $ydata_arr_ext[$tmp]=0;
		  $ydata_arr2[$tmp] =0;
		  $ydata_arr2_dvt[$tmp] =0;
		  $ydata_arr2_ext[$tmp] =0;
		  $ydata_arr3[$tmp]=0;
		  $ydata_arr3_dvt[$tmp]=0;
		  $ydata_arr3_ext[$tmp]=0;
		}
		
		
					
		while ($rowtt = mysql_fetch_array($resultcm)){
			for($j=$xaxis_num-1;$j>=0;$j--){
				//if ((($absolute*($j-1)+$end)<=$rowtt{'fad_date'} && $rowtt{'fad_date'}<= ($absolute*$j+$end))||(($absolute*($j-1)+$end)<=$rowtt{'lad_date'} && $rowtt{'lad_date'}<= ($absolute*$j+$end))){ 
					 // $ydata_arr[$xaxis_num-$j-1]+=$rowtt{'count(id)'};
					  //echo "j is $j<br>";
					 
				//}
				
				
				
		if (($absolute*$j+$end)<$rowtt{'fad_date'} && $rowtt{'fad_date'}<= ($absolute*($j+1)+$end)){ //this if for origination
			  $ydata_arr[$xaxis_num-$j-1]+=$rowtt{'count(id)'};
			 // break;
		  }
	      
		  if(($absolute*$j+$end)>0){
			if($rowtt{'lad_date'} <= ($absolute*($j+1)+$end) && $rowtt{'lad_date'} >= ($absolute*$j+$end)){
				$ydata_arr_ext[$xaxis_num-$j-1] += $rowtt{'count(id)'};
      
			}
		  }else{
			if($rowtt{'lad_date'} <= ($absolute*($j+1)+$end) && $rowtt{'lad_date'} > ($absolute*$j+$end)){
				$ydata_arr_ext[$xaxis_num-$j-1] += $rowtt{'count(id)'};
      
			}
		  
		  }
	      
		  if($rowtt{'fad_date'} <= ($absolute*($j+1)+$end) && $rowtt{'lad_date'} >= ($absolute*$j+$end)){
			$ydata_arr_dvt[$xaxis_num-$j-1] += $rowtt{'count(id)'};
			//break;
		  }
		  else if($rowtt{'fad_date'} < ($absolute*($j+1)+$end) && $rowtt{'fad_date'} > ($absolute*$j+$end)){
			$ydata_arr_dvt[$xaxis_num-$j-1] += $rowtt{'count(id)'};
			//break;
		  }
		  else if($rowtt{'lad_date'} < ($absolute*($j+1)+$end) && $rowtt{'lad_date'} > ($absolute*$j+$end)){
			$ydata_arr_dvt[$xaxis_num-$j-1] += $rowtt{'count(id)'};
      
			//break;
		  }
		  else if($rowtt{'fad_date'} >= ($absolute*($j+1)+$end) && $rowtt{'lad_date'} <= ($absolute*$j+$end)){
			$ydata_arr_dvt[$xaxis_num-$j-1] += $rowtt{'count(id)'};
			//break;
		  }
				
				
			}
		}
		while ($rowttmd = mysql_fetch_array($resultmd)) {
			for($j=$xaxis_num-1;$j>=0;$j--){
				//if ((($absolute*($j-1)+$end)<=$rowttmd{'fad_date'} && $rowttmd{'fad_date'}<= ($absolute*$j+$end))||(($absolute*($j-1)+$end)<=$rowttmd{'lad_date'} && $rowttmd{'lad_date'}<= ($absolute*$j+$end))){ 
					 // $ydata_arr2[$xaxis_num-$j-1]+=$rowttmd{'count(id)'};

				//}
				
				
				
		if (($absolute*$j+$end)<$rowttmd{'fad_date'} && $rowttmd{'fad_date'}<= ($absolute*($j+1)+$end)){ //this if for origination
			  $ydata_arr2[$xaxis_num-$j-1]+=$rowttmd{'count(id)'};
			 // break;
		  }
	      
		  if(($absolute*$j+$end)>0){
			if($rowttmd{'lad_date'} <= ($absolute*($j+1)+$end) && $rowttmd{'lad_date'} >= ($absolute*$j+$end)){
				$ydata_arr2_ext[$xaxis_num-$j-1] += $rowttmd{'count(id)'};
      
			}
		  }else{
			if($rowttmd{'lad_date'} <= ($absolute*($j+1)+$end) && $rowttmd{'lad_date'} > ($absolute*$j+$end)){
				$ydata_arr2_ext[$xaxis_num-$j-1] += $rowttmd{'count(id)'};
      
			}
		  
		  }
	      
		  if($rowttmd{'fad_date'} <= ($absolute*($j+1)+$end) && $rowttmd{'lad_date'} >= ($absolute*$j+$end)){
			$ydata_arr2_dvt[$xaxis_num-$j-1] += $rowttmd{'count(id)'};
			//break;
		  }
		  else if($rowttmd{'fad_date'} < ($absolute*($j+1)+$end) && $rowttmd{'fad_date'} > ($absolute*$j+$end)){
			$ydata_arr2_dvt[$xaxis_num-$j-1] += $rowttmd{'count(id)'};
			//break;
		  }
		  else if($rowttmd{'lad_date'} < ($absolute*($j+1)+$end) && $rowttmd{'lad_date'} > ($absolute*$j+$end)){
			$ydata_arr2_dvt[$xaxis_num-$j-1] += $rowttmd{'count(id)'};
      
			//break;
		  }
		  else if($rowttmd{'fad_date'} >= ($absolute*($j+1)+$end) && $rowttmd{'lad_date'} <= ($absolute*$j+$end)){
			$ydata_arr2_dvt[$xaxis_num-$j-1] += $rowttmd{'count(id)'};
			//break;
		  }
				
				
			
			}
		}
		
		while ($rowttpz = mysql_fetch_array($resultpz)) {
			for($j=$xaxis_num-1;$j>=0;$j--){
				//if ((($absolute*($j-1)+$end)<=$rowttpz{'fad_date'} && $rowttpz{'fad_date'}<= ($absolute*$j+$end))||(($absolute*($j-1)+$end)<=$rowttmpz{'lad_date'} && $rowttmpz{'lad_date'}<= ($absolute*$j+$end))){ 
					 // $ydata_arr3[$xaxis_num-$j-1]+=$rowttpz{'count(id)'};

				//}
				
				
				
		if (($absolute*$j+$end)<$rowttpz{'fad_date'} && $rowttpz{'fad_date'}<= ($absolute*($j+1)+$end)){ //this if for origination
			  $ydata_arr3[$xaxis_num-$j-1]+=$rowttpz{'count(id)'};
			 // break;
		  }
	      
		  if(($absolute*$j+$end)>0){
			if($rowttpz{'lad_date'} <= ($absolute*($j+1)+$end) && $rowttpz{'lad_date'} >= ($absolute*$j+$end)){
				$ydata_arr3_ext[$xaxis_num-$j-1] += $rowttpz{'count(id)'};
      
			}
		  }else{
			if($rowttpz{'lad_date'} <= ($absolute*($j+1)+$end) && $rowttpz{'lad_date'} > ($absolute*$j+$end)){
				$ydata_arr3_ext[$xaxis_num-$j-1] += $rowttpz{'count(id)'};
      
			}
		  
		  }
	      
		  if($rowttpz{'fad_date'} <= ($absolute*($j+1)+$end) && $rowttpz{'lad_date'} >= ($absolute*$j+$end)){
			$ydata_arr3_dvt[$xaxis_num-$j-1] += $rowttpz{'count(id)'};
			//break;
		  }
		  else if($rowttpz{'fad_date'} < ($absolute*($j+1)+$end) && $rowttpz{'fad_date'} > ($absolute*$j+$end)){
			$ydata_arr3_dvt[$xaxis_num-$j-1] += $rowttpz{'count(id)'};
			//break;
		  }
		  else if($rowttpz{'lad_date'} < ($absolute*($j+1)+$end) && $rowttpz{'lad_date'} > ($absolute*$j+$end)){
			$ydata_arr3_dvt[$xaxis_num-$j-1] += $rowttpz{'count(id)'};
      
			//break;
		  }
		  else if($rowttpz{'fad_date'} >= ($absolute*($j+1)+$end) && $rowttpz{'lad_date'} <= ($absolute*$j+$end)){
			$ydata_arr3_dvt[$xaxis_num-$j-1] += $rowttpz{'count(id)'};
			//break;
		  }
				
			
			}
		}
	
  }//end of if(key==1)
  
}//end of if relative=="none"
else{//$relative is not none
//$epoch_r=mysql_query("select * from stgintv");
$rltv_r=mysql_query("select * from $relative");
$i=0;
while($row=mysql_fetch_array($rltv_r)){
	$ydata_arr[$i]=0;
	$ydata_arr_dvt[$i]=0;
	$ydata_arr_ext[$i]=0;
	$i++;
}


while ($rowtt = mysql_fetch_array($resultcm)) {
	$rltv_r=mysql_query("select * from $relative"); //missed epoch "V"

	while($row=mysql_fetch_array($rltv_r)){
		//if(($rowtt{'fad_date'} <= $row{'begin'} && $rowtt{'fad_date'} >= $row{'end'})||($rowtt{'lad_date'} <=$row{'begin'} && $rowtt{'lad_date'} >= $row{'end'}))
		//{
			
		//	$ydata_arr[$row{'id'}] +=$rowtt{'count(id)'};
		//}
		
		
		if ($row{'end'}<$rowtt{'fad_date'} && $rowtt{'fad_date'}<= $row{'begin'}){ //this if for origination
			  $ydata_arr[$row{'id'}]+=$rowtt{'count(id)'};
			 // break;
		  }
	      
		  if($row{'end'}>0){
			if($rowtt{'lad_date'} < $row{'begin'} && $rowtt{'lad_date'} >= $row{'end'}){
				$ydata_arr_ext[$row{'id'}] += $rowtt{'count(id)'};
      
			}
		  }else{
			if($rowtt{'lad_date'} < $row{'begin'} && $rowtt{'lad_date'} > $row{'end'}){
				$ydata_arr_ext[$row{'id'}] += $rowtt{'count(id)'};
      
			}
		  
		  }
	      
		  if($rowtt{'fad_date'} <= $row{'begin'} && $rowtt{'lad_date'} >= $row{'end'}){
			$ydata_arr_dvt[$row{'id'}] += $rowtt{'count(id)'};
			//break;
		  }
		  else if($rowtt{'fad_date'} < $row{'begin'} && $rowtt{'fad_date'} > $row{'end'}){
			$ydata_arr_dvt[$row{'id'}] += $rowtt{'count(id)'};
			//break;
		  }
		  else if($rowtt{'lad_date'} < $row{'begin'} && $rowtt{'lad_date'} > $row{'end'}){
			$ydata_arr_dvt[$row{'id'}] += $rowtt{'count(id)'};
      
			//break;
		  }
		  else if($rowtt{'fad_date'} >= $row{'begin'} && $rowtt{'lad_date'} <= $row{'end'}){
			$ydata_arr_dvt[$row{'id'}] += $rowtt{'count(id)'};
			//break;
		  }		
		
	}//mark	
	  
   //echo "name:".$rowtt{'class_name'}." owner:".$rowtt{'fad_date'}."<br>";
}
//for($j=1;$j<=sizeof($epoch_arr); $j++)
	//echo "<br>arr $j is". $epoch_arr[$j];


$rltv_md=mysql_query("select * from $relative");
$i=0;
while($rowmd=mysql_fetch_array($rltv_md)){
	$ydata_arr2[$i]=0;
	$ydata_arr2_dvt[$i]=0;
	$ydata_arr2_ext[$i]=0;
	$i++;
}


while ($rowttmd = mysql_fetch_array($resultmd)) {
	$rltv_md=mysql_query("select * from $relative");

	while($rowmd=mysql_fetch_array($rltv_md)){
		//if(($rowttmd{'fad_date'} <= $rowmd{'begin'} && $rowttmd{'fad_date'} >= $rowmd{'end'})||($rowttmd{'lad_date'} <= $rowmd{'begin'} && $rowttmd{'lad_date'} >= $rowmd{'end'}))
		//{
			
		//	$ydata_arr2[$rowmd{'id'}] +=$rowttmd{'count(id)'};
		//}
		
		
		
		if ($rowmd{'end'}<$rowttmd{'fad_date'} && $rowttmd{'fad_date'}<= $rowmd{'begin'}){ //this if for origination
			  $ydata_arr2[$rowmd{'id'}]+=$rowttmd{'count(id)'};
			 // break;
		  }
	      
		  if($rowmd{'end'}>0){
			if($rowttmd{'lad_date'} < $rowmd{'begin'} && $rowttmd{'lad_date'} >= $rowmd{'end'}){
				$ydata_arr2_ext[$rowmd{'id'}] += $rowttmd{'count(id)'};
      
			}
		  }else{
			if($rowttmd{'lad_date'} < $rowmd{'begin'} && $rowttmd{'lad_date'} > $rowmd{'end'}){
				$ydata_arr2_ext[$rowmd{'id'}] += $rowttmd{'count(id)'};
      
			}		  
		  
		  }
	      
		  if($rowttmd{'fad_date'} <= $rowmd{'begin'} && $rowttmd{'lad_date'} >= $rowmd{'end'}){
			$ydata_arr2_dvt[$rowmd{'id'}] += $rowttmd{'count(id)'};
			//break;
		  }
		  else if($rowttmd{'fad_date'} < $rowmd{'begin'} && $rowttmd{'fad_date'} > $rowmd{'end'}){
			$ydata_arr2_dvt[$rowmd{'id'}] += $rowttmd{'count(id)'};
			//break;
		  }
		  else if($rowttmd{'lad_date'} < $rowmd{'begin'} && $rowttmd{'lad_date'} > $rowmd{'end'}){
			$ydata_arr2_dvt[$rowmd{'id'}] += $rowttmd{'count(id)'};
      
			//break;
		  }
		  else if($rowttmd{'fad_date'} >= $rowmd{'begin'} && $rowttmd{'lad_date'} <= $rowmd{'end'}){
			$ydata_arr2_dvt[$rowmd{'id'}] += $rowttmd{'count(id)'};
			//break;
		  }
		
		
		
		
	}//end of while($rowmd..)	  
}


//for($j=1;$j<=sizeof($epoch_arr2); $j++)
	//echo "<br>arr2 $j is". $epoch_arr2[$j];	
	
	
	
	
	
$rltv_pz=mysql_query("select * from $relative");
$i=0;
while($rowpz=mysql_fetch_array($rltv_pz)){
	$ydata_arr3[$i]=0;
	$ydata_arr3_dvt[$i]=0;
	$ydata_arr3_ext[$i]=0;
	$i++;
}


while ($rowttpz = mysql_fetch_array($resultpz)) {
	$rltv_pz=mysql_query("select * from $relative");

	while($rowpz=mysql_fetch_array($rltv_pz)){
		//if(($rowttpz{'fad_date'} <= $rowpz{'begin'} && $rowttpz{'fad_date'} >= $rowpz{'end'})||($rowttpz{'lad_date'} <= $rowpz{'begin'} && $rowttpz{'lad_date'} >= $rowpz{'end'}))
		//{
			
		//	$ydata_arr3[$rowpz{'id'}] +=$rowttpz{'count(id)'};
		//}
		
		
		
		if ($rowpz{'end'}<$rowttpz{'fad_date'} && $rowttpz{'fad_date'}<= $rowpz{'begin'}){ //this if for origination
			  $ydata_arr3[$rowpz{'id'}]+=$rowttpz{'count(id)'};
			 // break;
		  }
	      
		  if($rowpz{'end'}>0){
			if($rowttpz{'lad_date'} < $rowpz{'begin'} && $rowttpz{'lad_date'} >= $rowpz{'end'}){
				$ydata_arr3_ext[$rowpz{'id'}] += $rowttpz{'count(id)'};
      
			}
		  }else{
			if($rowttpz{'lad_date'} < $rowpz{'begin'} && $rowttpz{'lad_date'} > $rowpz{'end'}){
				$ydata_arr3_ext[$rowpz{'id'}] += $rowttpz{'count(id)'};
      
			}
		  
		  }
	      
		  if($rowttpz{'fad_date'} <= $rowpz{'begin'} && $rowttpz{'lad_date'} >= $rowpz{'end'}){
			$ydata_arr3_dvt[$rowpz{'id'}] += $rowttpz{'count(id)'};
			//break;
		  }
		  else if($rowttpz{'fad_date'} < $rowpz{'begin'} && $rowttpz{'fad_date'} > $rowpz{'end'}){
			$ydata_arr3_dvt[$rowpz{'id'}] += $rowttpz{'count(id)'};
			//break;
		  }
		  else if($rowttpz{'lad_date'} < $rowpz{'begin'} && $rowttpz{'lad_date'} > $rowpz{'end'}){
			$ydata_arr3_dvt[$rowpz{'id'}] += $rowttpz{'count(id)'};
      
			//break;
		  }
		  else if($rowttpz{'fad_date'} >= $rowpz{'begin'} && $rowttpz{'lad_date'} <= $rowpz{'end'}){
			$ydata_arr3_dvt[$rowpz{'id'}] += $rowttpz{'count(id)'};
			//break;
		  }
		
		
		
	}//end of while(rowpw=..)	  
}


}//end of else{ if relative not none

if($key==0){
	echo "Invalid time option. Please check your time selection or input and try again.<br><br>";
}
else{ //if key not 0
if($o=="on"){	
$File = "./specialgrh1Orig.php"; 
$Handle = fopen($File, 'w');
$Data = "<?php	
	
include (\"./src/jpgraph.php\");
include (\"./src/jpgraph_line.php\");
\$graph = new Graph(900,550,\"auto\");
\$graph->SetScale(\"textlin\");

\$graph->img->SetMargin(50,30,20,120);    
\$graph->SetShadow();

\$datax=array";
fwrite($Handle, $Data);
if($relative=="none"){
	//$x_label="(\"$from\"";
		$range=$absolute*$xaxis_num+$end;
		//for($i=2;$i<= $xaxis_num;$i++){
			
		//	$x_label=$x_label.","."\"".($range-$absolute*$i)."\"";
			//echo "it is ".($range-$absolute*$i)."<br>";
		//}
		
		
		
		$x_label="(\"$from"." - ".($range-$absolute)."\"";//ff
		for($i=1;$i<= $xaxis_num;$i++){//ff
			
			$x_label=$x_label.","."\"".($range-$absolute*$i)." - ".($range-$absolute*($i+1))."\"";//ff
			//echo "it is ".($range-$absolute*$i)."<br>";
		}
		
		$x_label=$x_label.")";
		$Data="$x_label;";
		fwrite($Handle, $Data);
		if($xaxis_num>50&&$xaxis_num<=100){
		$Data="
		\$graph->xaxis->SetTextTickInterval(2);
		";
		fwrite($Handle, $Data);
		}
		if($xaxis_num>100){
		$Data="
		 \$graph->xaxis->SetTextTickInterval(3);
		";
		fwrite($Handle, $Data);
  }
		
	
}
else{//if relative is not none
$rltv_r=mysql_query("select * from $relative where id=0");

$x_label="(";
while($row=mysql_fetch_array($rltv_r)){
	if($relative=="period") $x_label=$x_label."\"".$row{'pd_short'}."\"";
	else if($relative=="stage") $x_label=$x_label."\"".$row{'stage'}."\"";
		
	else $x_label=$x_label."\"".$row{'stage_interval'}."\"";
}
		
$rltv_r=mysql_query("select * from $relative where id>0") or die ("error selecting from stgintv!!");

while($row=mysql_fetch_array($rltv_r)){
		
	if($relative=="period") $x_label=$x_label.","."\"".$row{'pd_short'}."\"";
	else if($relative=="stage") $x_label=$x_label.","."\"".$row{'stage'}."\"";
	else $x_label=$x_label.","."\"".$row{'stage_interval'}."\"";
}

		$x_label=$x_label.")";
		$Data="$x_label;";
		fwrite($Handle, $Data);

} //end of else if relative is not none




//$x_label=$x_label.")";
//$Data="$x_label;
$Data="
\$datay=array";
fwrite($Handle, $Data);
$bary="(\"$ydata_arr[0]\"";
for($i=1; $i<sizeof($ydata_arr); $i++){
  $bary =$bary.","."\"".$ydata_arr[$i]."\"";
}
$bary=$bary.")";
$Data="$bary;

\$datay2=array";
fwrite($Handle, $Data);
$bary2="(\"$ydata_arr2[0]\"";
for($i=1; $i<sizeof($ydata_arr2); $i++){
  $bary2 =$bary2.","."\"".$ydata_arr2[$i]."\"";
}
$bary2=$bary2.")";
$Data="$bary2;

\$datay3=array";
fwrite($Handle, $Data);
$bary3="(\"$ydata_arr3[0]\"";
for($i=1; $i<sizeof($ydata_arr3); $i++){
  $bary3 =$bary3.","."\"".$ydata_arr3[$i]."\"";
}
$bary3=$bary3.")";
$Data="$bary3;


\$graph->title->Set(\"Sepkoski Curve/Special Graph 1 Origination\");
\$graph->title->SetFont(FF_FONT1,FS_BOLD);


\$dplot = new LinePLot(\$datay);
\$dplot2 = new LinePLot(\$datay2);
\$dplot3 = new LinePLot(\$datay3);

\$dplot->SetFillColor(\"blue\");
\$dplot2->SetFillColor(\"green\");
\$dplot3->SetFillColor(\"red\");

\$dplot->SetLegend(\"Cm\");
\$dplot2->SetLegend(\"Md\");
\$dplot3->SetLegend(\"Pz\");


// Create the accumulated graph
\$accplot = new AccLinePlot(array(\$dplot,\$dplot3, \$dplot2));

// Add the plot to the graph
\$graph->Add(\$accplot);

//\$p1 = new LinePlot(\$datay);
//\$p1->SetFillColor(\"blue\");
//\$p1->mark->SetType(MARK_FILLEDCIRCLE);
//\$p1->mark->SetFillColor(\"red\");
//\$p1->mark->SetWidth(4);
\$graph->yaxis->title->SetMargin(10);

\$graph->yaxis->title->Set(\"Number of Genera\");
\$graph->xaxis->SetTickLabels(\$datax);
\$graph->xaxis->SetLabelAngle(90);
\$graph->xaxis->title->SetMargin(80);";
fwrite($Handle, $Data);

if($relative=="none"){
$Data="
\$graph->xaxis->title->Set(\"Absolute Time\");
";
fwrite($Handle, $Data);
}

if($relative=="period"){
$Data="
\$graph->xaxis->title->Set(\"Period Interval\");
";
fwrite($Handle, $Data);
}

if($relative=="stage"){
$Data="
\$graph->xaxis->title->Set(\"Stage Interval\");
";
fwrite($Handle, $Data);
}

if($relative=="stgintv"){
$Data="
\$graph->xaxis->title->Set(\"Epoch Interval\");
";
fwrite($Handle, $Data);
}
$Data="
\$graph->Stroke();
?>";

fwrite($Handle, $Data);


$myFile = "./jpgraph_cache/specialgrh1Orig.png";
    if(file_exists($myFile)){
    unlink($myFile);
   }
}//end of if o==on












if($d=="on"){	
$File = "./specialgrh1Dvt.php"; 
$Handle = fopen($File, 'w');
$Data = "<?php	
	
include (\"./src/jpgraph.php\");
include (\"./src/jpgraph_line.php\");
\$graph = new Graph(900,550,\"auto\");
\$graph->SetScale(\"textlin\");

\$graph->img->SetMargin(50,30,20,120);    
\$graph->SetShadow();

\$datax=array";
fwrite($Handle, $Data);
if($relative=="none"){
	//$x_label="(\"$from\"";
		$range=$absolute*$xaxis_num+$end;
		//for($i=2;$i<= $xaxis_num;$i++){
			
			//$x_label=$x_label.","."\"".($range-$absolute*$i)."\"";
			//echo "it is ".($range-$absolute*$i)."<br>";
		//}
		
		
		$x_label="(\"$from"." - ".($range-$absolute)."\"";//ff
		for($i=1;$i<= $xaxis_num;$i++){//ff
			
			$x_label=$x_label.","."\"".($range-$absolute*$i)." - ".($range-$absolute*($i+1))."\"";//ff
			//echo "it is ".($range-$absolute*$i)."<br>";
		}
		
		$x_label=$x_label.")";
		$Data="$x_label;";
		fwrite($Handle, $Data);
		if($xaxis_num>50&&$xaxis_num<=100){
		$Data="
		\$graph->xaxis->SetTextTickInterval(2);
		";
		fwrite($Handle, $Data);
		}
		if($xaxis_num>100){
		$Data="
		 \$graph->xaxis->SetTextTickInterval(3);
		";
		fwrite($Handle, $Data);
  }
		
	
}
else{//if relative is not none
$rltv_r=mysql_query("select * from $relative where id=0");

$x_label="(";
while($row=mysql_fetch_array($rltv_r)){
	if($relative=="period") $x_label=$x_label."\"".$row{'pd_short'}."\"";
	else if($relative=="stage") $x_label=$x_label."\"".$row{'stage'}."\"";
		
	else $x_label=$x_label."\"".$row{'stage_interval'}."\"";
}
		
$rltv_r=mysql_query("select * from $relative where id>0") or die ("error selecting from stgintv!!");

while($row=mysql_fetch_array($rltv_r)){
		
	if($relative=="period") $x_label=$x_label.","."\"".$row{'pd_short'}."\"";
	else if($relative=="stage") $x_label=$x_label.","."\"".$row{'stage'}."\"";
	else $x_label=$x_label.","."\"".$row{'stage_interval'}."\"";
}

		$x_label=$x_label.")";
		$Data="$x_label;";
		fwrite($Handle, $Data);

} //end of else if relative is not none




//$x_label=$x_label.")";
//$Data="$x_label;
$Data="
\$datay=array";
fwrite($Handle, $Data);
$bary="(\"$ydata_arr_dvt[0]\"";
for($i=1; $i<sizeof($ydata_arr_dvt); $i++){
  $bary =$bary.","."\"".$ydata_arr_dvt[$i]."\"";
}
$bary=$bary.")";
$Data="$bary;

\$datay2=array";
fwrite($Handle, $Data);
$bary2="(\"$ydata_arr2_dvt[0]\"";
for($i=1; $i<sizeof($ydata_arr2_dvt); $i++){
  $bary2 =$bary2.","."\"".$ydata_arr2_dvt[$i]."\"";
}
$bary2=$bary2.")";
$Data="$bary2;

\$datay3=array";
fwrite($Handle, $Data);
$bary3="(\"$ydata_arr3_dvt[0]\"";
for($i=1; $i<sizeof($ydata_arr3_dvt); $i++){
  $bary3 =$bary3.","."\"".$ydata_arr3_dvt[$i]."\"";
}
$bary3=$bary3.")";
$Data="$bary3;


\$graph->title->Set(\"Sepkoski Curve/Special Graph 1 Diversity\");
\$graph->title->SetFont(FF_FONT1,FS_BOLD);


\$dplot = new LinePLot(\$datay);
\$dplot2 = new LinePLot(\$datay2);
\$dplot3 = new LinePLot(\$datay3);

\$dplot->SetFillColor(\"blue\");
\$dplot2->SetFillColor(\"green\");
\$dplot3->SetFillColor(\"red\");

\$dplot->SetLegend(\"Cm\");
\$dplot2->SetLegend(\"Md\");
\$dplot3->SetLegend(\"Pz\");


// Create the accumulated graph
\$accplot = new AccLinePlot(array(\$dplot,\$dplot3, \$dplot2));

// Add the plot to the graph
\$graph->Add(\$accplot);

//\$p1 = new LinePlot(\$datay);
//\$p1->SetFillColor(\"blue\");
//\$p1->mark->SetType(MARK_FILLEDCIRCLE);
//\$p1->mark->SetFillColor(\"red\");
//\$p1->mark->SetWidth(4);
\$graph->yaxis->title->SetMargin(10);

\$graph->yaxis->title->Set(\"Number of Genera\");
\$graph->xaxis->SetTickLabels(\$datax);
\$graph->xaxis->SetLabelAngle(90);
\$graph->xaxis->title->SetMargin(80);";
fwrite($Handle, $Data);


if($relative=="none"){
$Data="
\$graph->xaxis->title->Set(\"Absolute Time\");
";
fwrite($Handle, $Data);
}


if($relative=="period"){
$Data="
\$graph->xaxis->title->Set(\"Period Interval\");
";
fwrite($Handle, $Data);
}

if($relative=="stage"){
$Data="
\$graph->xaxis->title->Set(\"Stage Interval\");
";
fwrite($Handle, $Data);
}

if($relative=="stgintv"){
$Data="
\$graph->xaxis->title->Set(\"Epoch Interval\");
";
fwrite($Handle, $Data);
}
$Data="
\$graph->Stroke();
?>";

fwrite($Handle, $Data);


$myFile = "./jpgraph_cache/specialgrh1Dvt.png";
    if(file_exists($myFile)){
    unlink($myFile);
   }
}//end of if d==on











if($e=="on"){	
$File = "./specialgrh1Ext.php"; 
$Handle = fopen($File, 'w');
$Data = "<?php	
	
include (\"./src/jpgraph.php\");
include (\"./src/jpgraph_line.php\");
\$graph = new Graph(900,550,\"auto\");
\$graph->SetScale(\"textlin\");

\$graph->img->SetMargin(50,30,20,120);    
\$graph->SetShadow();

\$datax=array";
fwrite($Handle, $Data);
if($relative=="none"){
	//$x_label="(\"$from\"";
		$range=$absolute*$xaxis_num+$end;
		//for($i=2;$i<= $xaxis_num;$i++){
			
			//$x_label=$x_label.","."\"".($range-$absolute*$i)."\"";
			//echo "it is ".($range-$absolute*$i)."<br>";
		//}
		
		
		$x_label="(\"$from"." - ".($range-$absolute)."\"";//ff
		for($i=1;$i<= $xaxis_num;$i++){//ff
			
			$x_label=$x_label.","."\"".($range-$absolute*$i)." - ".($range-$absolute*($i+1))."\"";//ff
			//echo "it is ".($range-$absolute*$i)."<br>";
		}
		
		
		$x_label=$x_label.")";
		$Data="$x_label;";
		fwrite($Handle, $Data);
		if($xaxis_num>50&&$xaxis_num<=100){
		$Data="
		\$graph->xaxis->SetTextTickInterval(2);
		";
		fwrite($Handle, $Data);
		}
		if($xaxis_num>100){
		$Data="
		 \$graph->xaxis->SetTextTickInterval(3);
		";
		fwrite($Handle, $Data);
  }
		
	
}
else{//if relative is not none
$rltv_r=mysql_query("select * from $relative where id=0");

$x_label="(";
while($row=mysql_fetch_array($rltv_r)){
	if($relative=="period") $x_label=$x_label."\"".$row{'pd_short'}."\"";
	else if($relative=="stage") $x_label=$x_label."\"".$row{'stage'}."\"";
		
	else $x_label=$x_label."\"".$row{'stage_interval'}."\"";
}
		
$rltv_r=mysql_query("select * from $relative where id>0") or die ("error selecting from stgintv!!");

while($row=mysql_fetch_array($rltv_r)){
		
	if($relative=="period") $x_label=$x_label.","."\"".$row{'pd_short'}."\"";
	else if($relative=="stage") $x_label=$x_label.","."\"".$row{'stage'}."\"";
	else $x_label=$x_label.","."\"".$row{'stage_interval'}."\"";
}

		$x_label=$x_label.")";
		$Data="$x_label;";
		fwrite($Handle, $Data);

} //end of else if relative is not none




//$x_label=$x_label.")";
//$Data="$x_label;
$Data="
\$datay=array";
fwrite($Handle, $Data);
$bary="(\"$ydata_arr_ext[0]\"";
for($i=1; $i<sizeof($ydata_arr_ext); $i++){
  $bary =$bary.","."\"".$ydata_arr_ext[$i]."\"";
}
$bary=$bary.")";
$Data="$bary;

\$datay2=array";
fwrite($Handle, $Data);
$bary2="(\"$ydata_arr2_ext[0]\"";
for($i=1; $i<sizeof($ydata_arr2_ext); $i++){
  $bary2 =$bary2.","."\"".$ydata_arr2_ext[$i]."\"";
}
$bary2=$bary2.")";
$Data="$bary2;

\$datay3=array";
fwrite($Handle, $Data);
$bary3="(\"$ydata_arr3_ext[0]\"";
for($i=1; $i<sizeof($ydata_arr3_ext); $i++){
  $bary3 =$bary3.","."\"".$ydata_arr3_ext[$i]."\"";
}
$bary3=$bary3.")";
$Data="$bary3;


\$graph->title->Set(\"Sepkoski Curve/Special Graph 1 Extinction\");
\$graph->title->SetFont(FF_FONT1,FS_BOLD);


\$dplot = new LinePLot(\$datay);
\$dplot2 = new LinePLot(\$datay2);
\$dplot3 = new LinePLot(\$datay3);

\$dplot->SetFillColor(\"blue\");
\$dplot2->SetFillColor(\"green\");
\$dplot3->SetFillColor(\"red\");

\$dplot->SetLegend(\"Cm\");
\$dplot2->SetLegend(\"Md\");
\$dplot3->SetLegend(\"Pz\");


// Create the accumulated graph
\$accplot = new AccLinePlot(array(\$dplot,\$dplot3, \$dplot2));

// Add the plot to the graph
\$graph->Add(\$accplot);

//\$p1 = new LinePlot(\$datay);
//\$p1->SetFillColor(\"blue\");
//\$p1->mark->SetType(MARK_FILLEDCIRCLE);
//\$p1->mark->SetFillColor(\"red\");
//\$p1->mark->SetWidth(4);
\$graph->yaxis->title->SetMargin(10);

\$graph->yaxis->title->Set(\"Number of Genera\");
\$graph->xaxis->SetTickLabels(\$datax);
\$graph->xaxis->SetLabelAngle(90);
\$graph->xaxis->title->SetMargin(80);";
fwrite($Handle, $Data);


if($relative=="none"){
$Data="
\$graph->xaxis->title->Set(\"Absolute Time\");
";
fwrite($Handle, $Data);
}


if($relative=="period"){
$Data="
\$graph->xaxis->title->Set(\"Period Interval\");
";
fwrite($Handle, $Data);
}

if($relative=="stage"){
$Data="
\$graph->xaxis->title->Set(\"Stage Interval\");
";
fwrite($Handle, $Data);
}

if($relative=="stgintv"){
$Data="
\$graph->xaxis->title->Set(\"Epoch Interval\");
";
fwrite($Handle, $Data);
}
$Data="
\$graph->Stroke();
?>";

fwrite($Handle, $Data);


$myFile = "./jpgraph_cache/specialgrh1Ext.png";
    if(file_exists($myFile)){
    unlink($myFile);
   }
}//end of if e==on









if($d== "on"){
    if($o=="on"){
      if($e=="on"){
        echo "<div class=\"tabber\" id=\"tab1\">";          

          echo "<div class=\"tabbertab\" title=\"Diversity\">";
		  
		  echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameDvt\" type=\"text\" id=\"textnameDvt\" size=\"35\" />
			<input type=\"button\" name=\"givenameDvt\" id=\"givenameDvt\" onclick='ajaxname(\"Dvt\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameDiv'>";
		  
          echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Dvt.php\">";
		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Dvt.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";
		  //echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Dvt.php\">";
          echo "</div>"; //div for ajax
		  
		  echo "</div>"; 
          
          echo "<div class=\"tabbertab\" title=\"Origination\">";
			echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameOrig\" type=\"text\" id=\"textnameOrig\" size=\"35\" />
			<input type=\"button\" name=\"givenameOrig\" id=\"givenameOrig\" onclick='ajaxname(\"Orig\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameOrig'>";
		  
          echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Orig.php\">"; 
		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Orig.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";
		  
		  //echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Orig.php\">";
          echo "</div>"; //for ajax
		  echo "</div>";


          echo "<div class=\"tabbertab\" title=\"Extinction\">";
			echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameExt\" type=\"text\" id=\"textnameExt\" size=\"35\" />
			<input type=\"button\" name=\"givenameExt\" id=\"givenameExt\" onclick='ajaxname(\"Ext\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameExt'>";
		  
		  
          echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Ext.php\">";
		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Ext.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";
		  
		  //echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Ext.php\">";
          echo "</div>";//div for ajax
		  echo "</div>";
		  
        echo "</div>";
      
      }
      else { // e is not on, o and d are on    
        echo "<div class=\"tabber\" id=\"tab1\">";
		echo "<div class=\"tabbertab\" title=\"Diversity\">";
			echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameDvt\" type=\"text\" id=\"textnameDvt\" size=\"35\" />
			<input type=\"button\" name=\"givenameDvt\" id=\"givenameDvt\" onclick='ajaxname(\"Dvt\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameDiv'>";

          
          echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Dvt.php\">";

		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Dvt.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";

		  //echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Dvt.php\">";
          echo "</div>";//end of ajax for this tab
		  echo "</div>";
          
          echo "<div class=\"tabbertab\" title=\"Origination\">";
			echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameOrig\" type=\"text\" id=\"textnameOrig\" size=\"35\" />
			<input type=\"button\" name=\"givenameOrig\" id=\"givenameOrig\" onclick='ajaxname(\"Orig\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameOrig'>";
		  
          echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Orig.php\">"; 

		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Orig.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";

		  //echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Orig.php\">"; 
          echo "</div>";//end of ajax
		  echo "</div>";
		  
        echo "</div>";      
      }    
    }
    else{ //o is not on, d is on, e is on or not
      if($e=="on"){ //d is on and e is on, o not on
        echo "<div class=\"tabber\" id=\"tab1\">"; 
		echo "<div class=\"tabbertab\" title=\"Diversity\">";
			echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameDvt\" type=\"text\" id=\"textnameDvt\" size=\"35\" />
			<input type=\"button\" name=\"givenameDvt\" id=\"givenameDvt\" onclick='ajaxname(\"Dvt\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameDiv'>";

          
          echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Dvt.php\">";

		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Dvt.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";

		  //echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Dvt.php\">";
          echo "</div>";
		  echo "</div>"; //end of ajax
          
          echo "<div class=\"tabbertab\" title=\"Extinction\">";
			echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameExt\" type=\"text\" id=\"textnameExt\" size=\"35\" />
			<input type=\"button\" name=\"givenameExt\" id=\"givenameExt\" onclick='ajaxname(\"Ext\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameExt'>";
		  
          echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Ext.php\">";

		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Ext.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";

		  //echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Ext.php\">";
          echo "</div>";//end of ajax		  
		echo "</div>";
        echo "</div>";     
      
      }
      else{ //e and o are not on
        echo "<div class=\"tabber\" id=\"tab1\">";          

          echo "<div class=\"tabbertab\" title=\"Diversity\">";
		  echo "Provide a New Name for the Graph: ";
		  echo "<input name=\"textnameDvt\" type=\"text\" id=\"textnameDvt\" size=\"35\" />
			<input type=\"button\" name=\"givenameDvt\" id=\"givenameDvt\" onclick='ajaxname(\"Dvt\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameDiv'>";
          echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Dvt.php\">";

		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Dvt.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";

		  //echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Dvt.php\">";
          echo "</div>";          
          echo "</div>";
        echo "</div>";      
      
      }    
    }// for 'else{ //o is not on, d is on, e is on or not'
  
  }
  else{ //$d is not on
    if($o=="on"){
      if($e=="on"){
          echo "<div class=\"tabber\" id=\"tab1\">";  
            echo "<div class=\"tabbertab\" title=\"Origination\">";
			echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameOrig\" type=\"text\" id=\"textnameOrig\" size=\"35\" />
			<input type=\"button\" name=\"givenameOrig\" id=\"givenameOrig\" onclick='ajaxname(\"Orig\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameOrig'>";
			
            echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Orig.php\">";
			
		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Orig.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";

			
			//echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Orig.php\">";
            echo "</div>"; 
			echo "</div>";
			
            echo "<div class=\"tabbertab\" title=\"Extinction\">";
			echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameExt\" type=\"text\" id=\"textnameExt\" size=\"35\" />
			<input type=\"button\" name=\"givenameExt\" id=\"givenameExt\" onclick='ajaxname(\"Ext\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameExt'>";
			
            echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Ext.php\">";
			
		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Ext.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";

			
			//echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Ext.php\">";
            echo "</div>";			
			echo "</div>";	
          echo "</div>";
      
      }else{ //only o is on
          echo "<div class=\"tabber\" id=\"tab1\">";  
            echo "<div class=\"tabbertab\" title=\"Origination\">";
			echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameOrig\" type=\"text\" id=\"textnameOrig\" size=\"35\" />
			<input type=\"button\" name=\"givenameOrig\" id=\"givenameOrig\" onclick='ajaxname(\"Orig\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameOrig'>";
			
            echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Orig.php\">";
			
		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Orig.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";

			
			//echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Orig.php\">"; 
            echo "</div>";            
          echo "</div>";
		  echo "</div>";
      
      }    
    
    }
    else { // d and o are off
      if ($e =="on"){
        echo "<div class=\"tabber\" id=\"tab1\">";  
            echo "<div class=\"tabbertab\" title=\"Extinction\">";
			echo "Provide a New Name for the Graph: ";
			echo "<input name=\"textnameExt\" type=\"text\" id=\"textnameExt\" size=\"35\" />
			<input type=\"button\" name=\"givenameExt\" id=\"givenameExt\" onclick='ajaxname(\"Ext\")' value=\"Change Name\" /><br>
			<br>
		
			</br>";
			echo "<div id='ajaxnameExt'>";
			
            echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Ext.php\">";
			
		  echo "<br><br></br><a href=\"http://www.fossilplot.org/test/graph/jpgraph_cache/specialgrh1Ext.png\" target=\"_blank\"><font size=\"1\"> Download/Print Graph</font></a>";

			
			//echo "<img src=\"http://www.fossilplot.org/test/graph/specialgrh1Ext.php\">";
            echo "</div>";
          echo "</div>";
		  echo "</div>";
      
      }
      else{ //d,o,x are off
        echo "please select Diversity, Origination, or Extinction for the graph.";
      
      }
    
    
    }
  
  
  }



} //end of else(key!=0)
}//end of if($cat)
else{
echo "<br><br>Please select the radio box in front of \"Sepkoski Curve\" to get the time options for this graph.<br><br>";
}
?>

<?php include 'footer.php';?>

</body>
</html>